# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : p3.py
# @Time     : 2024/5/7 22:56
# @Author   : Robot-Zsj
"""
description:

螺旋数字矩阵

https://fcqian.blog.csdn.net/article/details/135085069?spm=1001.2014.3001.5502

i:
9 4

o:
1 2 3
* * 4
9 * 5
8 7 6
"""

import math

n, m = map(int, input().split())


def getResult():
    k = int(math.ceil(n / m))

    matrix = [['*'] * k for _ in range(m)]

    step = 1

    x = 0
    y = 0

    while step <= n:
        while y < k and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            y += 1
        y -= 1
        x += 1

        while x < m and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            x += 1
        x -= 1
        y -= 1

        while y >= 0 and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            y -= 1
        y += 1
        x -= 1

        while x >= 0 and matrix[x][y] == '*' and step <= n:
            matrix[x][y] = str(step)
            step += 1
            x -= 1
        x += 1
        y += 1

    for i in range(m):
        print(" ".join(matrix[i]))


getResult()
